<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ice="http://www.icesoft.com/icefaces/component">
<head>
<title><ui:insert name="title">My Micro Blog - MyMiB</ui:insert></title>
<link rel="stylesheet" type="text/css" href="./woodstock/woodstock.css" />
</head>
<body>
<f:view>
	<ice:form method="POST" action="/j_security_check">
		<div id="header"><ice:panelBorder width="100%">
			<f:facet name="north">
				<ice:panelGrid columns="1" width="100%">
					<ice:panelGroup style="text-align:center;">
						<h1>#{mymibMBean.titulo}</h1>
						<ice:panelGroup>
							<ice:outputLabel value="#{mymibMBean.tema}" />
							<br />
							<ice:outputLabel value="#{mymibMBean.frase}" />
						</ice:panelGroup>
					</ice:panelGroup>
				</ice:panelGrid>
			</f:facet>
			<f:facet name="east">
				<ice:panelGrid columns="1" width="200">
					<ice:panelGroup>
						<ice:commandLink action="toLogin"
							rendered="#{!(validateLoginMBean.validateUser)}">
							<ice:outputLabel value="Efetuar Login" />
						</ice:commandLink>
						<ice:panelGrid border="1" columns="2" renderedOnUserRole="GRANTED">
							<ice:outputText value="#{mymibMBean.usuario}" />
							<ice:commandLink action="#{validateLoginMBean.invalidateSession}">
								<ice:outputLabel value=" Logout" />
							</ice:commandLink>
						</ice:panelGrid>
						<ice:panelGrid border="1" columns="2" renderedOnUserRole="ADMIN">
							<ice:outputText value="admin" />
							<ice:commandLink action="#{validateLoginMBean.invalidateSession}">
								<ice:outputLabel value=" Logout" />
							</ice:commandLink>
						</ice:panelGrid>
					</ice:panelGroup>
					<ice:panelGrid columns="2"
						rendered="#{!(validateLoginMBean.validateUser)}">
						<ice:outputLabel value="Cadastrar" />
						<ice:commandButton
							image="./woodstock/css-images/button/update.png"
							actionListener="#{registerMBean.exibirWindow}" />
					</ice:panelGrid>
					<ice:panelGrid columns="2" renderedOnUserRole="ADMIN,GRANTED" > <!--  rendered="#{(validateLoginMBean.validateUser)}" -->
						<ice:outputLabel value="Alterar Senha" />
						<ice:commandButton image="./woodstock/css-images/button/find.gif"
							actionListener="#{changePwdMBean.exibirWindow}"/>
					</ice:panelGrid>
					<ice:panelGrid columns="2"
						rendered="#{(validateLoginMBean.validateUser)}">
						<ice:outputLabel value="Meus posts" />
						<ice:commandButton
							image="./woodstock/css-images/button/folder.gif"
							actionListener="#{userPostsMBean.exibirWindow}" />
					</ice:panelGrid>
					<ice:panelGrid columns="2">
						<ice:outputLabel value="Procurar posts" />
						<ice:commandButton image="./woodstock/css-images/button/find.gif"
							actionListener="#{findPostMBean.exibirWindow}" />
					</ice:panelGrid>

					<ice:panelGrid columns="2" renderedOnUserRole="ADMIN">
						<ice:outputLabel value="Configurar" />
						<ice:commandButton image="./woodstock/css-images/button/find.gif"
							actionListener="#{configMBean.exibirWindow}" />
					</ice:panelGrid>
					
					<ice:panelGrid columns="1">
						<img src="./woodstock/css-images/others/mymib_desc.gif" />
					</ice:panelGrid>
				</ice:panelGrid>
			</f:facet>
			<f:facet name="center">
				<ice:panelGroup width="100%">
					<ice:commandLink actionListener="#{postMBean.abrirWindow}"
						renderedOnUserRole="GRANTED">
						<ice:outputLabel value="Novo Post" />
					</ice:commandLink>
					<ui:repeat value="#{postMBean.posts}" var="post">
						<ice:panelCollapsible styleClass="#{configMBean.panelStyle}">
							<f:facet name="header">
								<ice:panelGroup>
									<ice:panelGrid>
										<ice:outputText value="#{post.assunto}" />
										<ui:repeat value="#{post.tags}" var="tag">
											<ice:commandLink style="font-color:blue;">
												<ice:outputText value="#{tag}" />
											</ice:commandLink>
										</ui:repeat>
									</ice:panelGrid>
									<ice:panelGrid columns="2">
										<ice:outputText value="Autor:" />
										<ice:outputText value="#{post.autor}" />
									</ice:panelGrid>
								</ice:panelGroup>
							</f:facet>
							<ice:panelGroup style="border-bottom: 3px dashed gray; ">
								<br />
								<br />
								<ice:outputText value="#{post.mensagem}" />
								<br />
							</ice:panelGroup>

							<ui:repeat value="#{post.comentarios}" var="com">
								<ice:panelGrid columns="1" width="100%"
									style="border: 1px gray solid;">
									<ice:outputText value="#{com.conteudo}" />
									<ice:panelGrid columns="3" width="100%">
										<ice:outputText value="#{com.autor}" />
										<ice:outputText value="#{com.data}" />
									</ice:panelGrid>
								</ice:panelGrid>
								<br />
								<br />
							</ui:repeat>
							<br />
							<ice:commandButton value="Comentar"
								actionListener="#{comentarioMBean.exibirWindow}">
								<f:attribute value="#{post.id}" name="postId" />
							</ice:commandButton>
						</ice:panelCollapsible>
					</ui:repeat>
				</ice:panelGroup>
			</f:facet>
			<f:facet name="south">
				<ice:panelGroup style="color:gray; text-align:center; font-size:10px;">
					<ice:outputLabel value="#{mymibMBean.cc}" />
				</ice:panelGroup>
			</f:facet>
		</ice:panelBorder></div>
		<div id="content"></div>
	</ice:form>
	<ui:include src="/private/viewComentario.xhtml" />
	<ui:include src="/private/viewNewPost.xhtml" />
	<ui:include src="/private/viewUserPosts.xhtml" />
	<ui:include src="/private/viewFindPosts.xhtml" />
	<ui:include src="/private/viewRegister.xhtml" />
	<ui:include src="/private/viewChangePwd.xhtml" />
	<ui:include src="/admin/viewConfig.xhtml" />
</f:view>
</body>
</html>